﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.Models;
using SWDataDB.BLL;
using SWDataDB.DAL;
using System.Data;
 


public partial class AdminManage_Edit_WJEdit : System.Web.UI.Page
{

    public string xgid = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        xgid = Request["xgid"];
        bind();
    }


    private void bind()
    {
        XGInfo xgquery = new XGInfo();
        int XGID = Convert.ToInt32(xgid);
        DataSet ds = xgquery.SelectInfoByFileID(XGID);
        DataRowView dv = ds.Tables[0].DefaultView[0];

        
        
      
        ZL_FILE_ID.Text = Convert.ToString(dv.Row["ZL_FILE_ID"]);


        XG_CODE.Text = Convert.ToString(dv.Row["XG_CODE"]);
        DATA_STYLE.Text = Convert.ToString(dv.Row["DATA_STYLE"]);
        DATA_NAME.Text = Convert.ToString(dv.Row["DATA_NAME"]);
        SCALE.Text = Convert.ToString(dv.Row["SCALE"]);



        NUM.Text = Convert.ToString(dv.Row["NUM"]);
        


        //从著录表中读取title
        ZLInfo ZLFILEID = new ZLInfo();
        ZL_TBL zl = ZLFILEID.SelectZLInfoByID(dv.Row["ZL_FILE_ID"].ToString());
        TITLE_.Text = zl.O_TITLE;
        FileTitle.Text = zl.O_TITLE;


    }


    protected void submit_Click(object sender, EventArgs e)
    {
        XGDATA_TBL xg_info = new XGDATA_TBL();
        XGInfo kc_in = new XGInfo();

        xg_info.O_ZL_FILE_ID = Request.Form["ZL_FILE_ID"];
        xg_info.O_XG_CODE = Request.Form["XG_CODE"];
        xg_info.O_DATA_STYLE = Request.Form["DATA_STYLE"];


        xg_info.O_DATA_NAME = Request.Form["DATA_NAME"];
        xg_info.O_SCALE =Request.Form["SCALE"];
        xg_info.O_NUM = Request.Form["NUM"].Trim().Length == 0 ? 0 : int.Parse((Request.Form["NUM"]));
      


        xg_info.O_ID = int.Parse(xgid);

        if (kc_in.UpdateXGInfo(xg_info) == 1)
        {
            bind();
            Response.Write("<script language=javascript>alert('更新成功！');location='../Manage/WJManage.aspx'</script>");
            //Response.Redirect("ZLManage.aspx");
        }
        else
        {
            Response.Write("<script language=javascript>alert('更新失败！');location='../Manage/WJManage.aspx'</script>");
        }
    }
}